<template>
	<view class="container">
		<view class="none" v-if="result.length==0">没有记录</view>
		<view class="order_unit"  v-for="(item,index) in result" :key="index" v-else>
			<image class="avatar" :src="item.img" v-if="item.img.length>10"></image>
			<image class="avatar" :src="static_url+'/logo.png'" v-else></image>
			<view class="content">
				<view class="nickname">
					{{item.nickname}}
					<!-- <view class="grade" v-if="item.grade==1"><image :src="static_url+'/x.png'"></image>健康管家</view>
					<view class="grade" v-if="item.grade==2"><image :src="static_url+'/y.png'"></image>健康顾问</view> -->
				</view>
				<view class="order_num">待领取记录：<text>{{item.achievement_399}}</text></view>
				<view class="status1" :id="item.member_id" v-if="item.achievement_399_status==1" v-on:click="operate">待结算</view>
				<view class="status2" v-if="item.achievement_399_status==2">已结算</view>
				<view class="status2" v-if="item.achievement_399_status==0">待门店结算</view>
			</view>
		</view>
	</view>
</template>
<style>
	page{background: #F4F4F4;}
	.container{width:100%;}
	.content{width: 60%;display: flex;justify-content: center;align-items: center;flex-direction: column;}
	.none{width:100%;height: 80upx;line-height: 80upx;text-align: center;font-size: 28upx;}
	.order_unit{width:92%;margin:10upx 2%;padding:10upx 2%;background:#FFFFFF;display: flex;justify-content: space-between;}
	.avatar{width:200upx;height: 200upx;border-radius: 100upx;margin:0 10upx 0 0;}
	.nickname{width:100%;display: flex;justify-content: flex-start;align-items: center;font-size: 28upx;}
	.order_num{width:100%;font-size: 26upx;line-height: 70upx;font-size: 28upx;color: #999999;}
	.unit{width:5%;display: flex;justify-content: center;align-items: center;}
	.grade{padding:8upx 20upx;display:flex;justify-content: flex-start;align-items: center;text-align: center;height: 30upx;line-height:30upx;;border-radius: 20upx;background: #e8c99c;font-size:24upx;}
	.grade image{width:25upx;height:25upx;}
	.n{color: #333333;}
	.status1{width:100%;line-height: 70upx;text-align: center;border-radius: 35upx;background-image: linear-gradient(#43eac9, #24c3a4);color:#ffffff;
			font-size: 28upx;}
	.status2{width:100%;line-height: 70upx;text-align: center;border-radius: 35upx;background:#ccc;color:#ffffff;
			font-size: 28upx;}
</style>
<script>
	export default {
		data() {
			return {
				current: 1,
				pic_h:'',
				result:[],
				start:0,
				submit_status:1,
				refresh_status:0,
				switch1:0,
				price:0,
				url: getApp().globalData.url,
				static_url:getApp().globalData.static
			}
		},
		onLoad(e) {
			var res = uni.getSystemInfoSync();
			var w = res.windowWidth;
			this.pic_h = w*0.92*0.2+"px";
			this.initialize();
		},
		onReachBottom(){
			this.initialize();
		},
		methods: {
			operate:function()
			{
				var that = this;
				var member_id = e.currentTarget.id;
				uni.showModal({
					title:"操作提示",
					content:"点击确认，结算该数据？",
					success: (show_res) => {
						if(show_res.confirm)
						{
							uni.request({
								url: this.url+"/wechat_settlement_salesman",
								data: {member_id:member_id,status:2},
								header: {'Content-Type': 'application/json'},
								success: function (res) 
								{
									if(res.data.status==1)
									{
										uni.showToast({
											title:"操作成功"
										})
										that.start = 0;
										setTimeout(()=>{that.initialize()},1500);
									}
									
								}
							})
						}
					}
				})
			},
			initialize:function()
			{
				var that = this;
				var member_id = uni.getStorageSync("member_id");
				uni.request({
					url: this.url+'/wechat_salesman_info', 
					data: {member_id:member_id,start:this.start},
					header: {'Content-Type': 'application/json'},
					success: (res) => {
						console.log(res);
						if(res.data.status==1)
						{
							if(that.start==0)
							{
								that.result = res.data.result;
							}
							else
							{
								for(var i=0;i<res.data.result.length;i++)
								{
									that.result.push(res.data.result[i]);
								}
							}
							that.start += 10;
						}
					}
				});
			}
		}
	}
</script>


